﻿Imports HMSLibrary
Imports Microsoft.Win32

Public Class AboutUsWindow
    Private Sub MainWindow_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Input.MouseButtonEventArgs) Handles Me.MouseDown
        DragMove()
    End Sub

    Private Sub CloseButton_Click(ByVal sender As Object, ByVal e As System.Windows.RoutedEventArgs) Handles CloseButton.Click
        Me.Hide()
    End Sub

    Private Sub MinimizeButton_Click(ByVal sender As Object, ByVal e As System.Windows.RoutedEventArgs) Handles MinimizeButton.Click
        Me.WindowState = Windows.WindowState.Minimized
    End Sub

    Private Sub RegisterButton_Click(ByVal sender As System.Object, ByVal e As System.Windows.RoutedEventArgs)
        If LicenseNoTextBox.Text.Trim.Length < 16 Then
            CommonMessages.ShowValidationMsg("Please enter correct license no!")
            Exit Sub
        End If
        Dim lstLic As List(Of String)
        lstLic = Licence.getLicenceKey
        LicenseNoTextBox.Text = LicenseNoTextBox.Text.Replace("-", "")
        For i As Integer = 4 To 14
            LicenseNoTextBox.Text = LicenseNoTextBox.Text.Insert(i, "-")
            i = i + 4
        Next
        Dim objTemp = (From lkey In lstLic Where lkey = LicenseNoTextBox.Text Select lkey).FirstOrDefault
        If objTemp IsNot Nothing Then
            Dim regKey As RegistryKey
            regKey = Registry.CurrentUser.OpenSubKey("Software\" & My.Application.Info.CompanyName, True)
            regKey.SetValue("led", True)
            regKey.SetValue("lto", NameTextBox.Text)
        End If
    End Sub
End Class
